package springbootweb02.controller;

import org.springframework.web.bind.annotation.*;
import springbootweb02.pojo.User;


import java.util.Arrays;
import java.util.List;
//纯注解开发
@RestController
@RequestMapping("/user")
public class ParamController {
    @GetMapping("/commonParamDifferentName")
    public String paramcontroller(String name,String age){
        System.out.println(name+"年龄"+age);
        return name;
    }
    @PostMapping("commonParamDifferentName")
    public String select(String name,Integer age){
        System.out.println("名字："+name+age);
        return "ok";
    }
    @GetMapping("/pojoParam")
    public String from(User user){
        System.out.println(user);
        return "ok";
    }
    @PostMapping("/pojoParam")
    public String where(User user){
        System.out.println(user);
        return "ok";
    }

    @PostMapping("/pojoContainPojoParam")
    public String groutby(User user){
        System.out.println(user);
        return "ok";
    }
    @PostMapping("/arrayParam")
    public String oroutby(@RequestParam("likes") String[]  like){
        System.out.println(Arrays.toString(like));
        return "ok";
    }
    @PostMapping("listParam")
    public String di(@RequestParam List<String> likes){
        //这个注解 告诉集合接口是用来装东西的
        for (String like : likes) {
            System.out.println(like);
        }
        return "ok";
    }
    @PostMapping("pojoParamForJson")
    public String param(@RequestBody User user){
        //如果传递的是json  则一定是在请求体中 所以要冲请求体拿
        System.out.println(user);
        return "ok";
    }
}






















